/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gerenciadorfinanceiro.database.resources;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author eduardo
 */
@Entity
@Table(name = "income")
@NamedQueries({@NamedQuery(name = "Income.findAllByUserMonth", query = "SELECT i FROM Income i WHERE owner = :owner and month(data) = :month and year(data) = :year"), @NamedQuery(name = "Income.findAll", query = "SELECT i FROM Income i"), @NamedQuery(name = "Income.findById", query = "SELECT i FROM Income i WHERE i.id = :id"), @NamedQuery(name = "Income.findByDescriptionIncome", query = "SELECT i FROM Income i WHERE i.descriptionIncome = :descriptionIncome"), @NamedQuery(name = "Income.findByValue", query = "SELECT i FROM Income i WHERE i.value = :value"), @NamedQuery(name = "Income.findByData", query = "SELECT i FROM Income i WHERE i.data = :data")})
public class Income implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "descriptionIncome")
    private String descriptionIncome;
    @Basic(optional = false)
    @Column(name = "value")
    private double value;
    @Basic(optional = false)
    @Column(name = "data")
    @Temporal(TemporalType.DATE)
    private Date data;
    @JoinColumn(name = "owner", referencedColumnName = "id_user")
    @ManyToOne(optional = false)
    private User owner;

    public Income() {
    }

    public Income(Integer id) {
        this.id = id;
    }

    public Income(Integer id, String descriptionIncome, double value, Date data) {
        this.id = id;
        this.descriptionIncome = descriptionIncome;
        this.value = value;
        this.data = data;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getDescriptionIncome() {
        return descriptionIncome;
    }

    public void setDescriptionIncome(String descriptionIncome) {
        this.descriptionIncome = descriptionIncome;
    }

    public double getValue() {
        return value;
    }

    public void setValue(double value) {
        this.value = value;
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public User getOwner() {
        return owner;
    }

    public void setOwner(User owner) {
        this.owner = owner;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Income)) {
            return false;
        }
        Income other = (Income) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gerenciadorfinanceiro.database.resources.Income[id=" + id + "]";
    }

}
